Vue.component("myheader",{
    template:`
     <header>
        <div class="c900 flex">
            <a href="./"><h1 style="color: #fdfdfd">志愿者平台</h1></a>
            <span class="flex">
                <span v-if="user">
                    <a href="home.html"><el-avatar :src="user.head"></el-avatar></a>
                    <a href="add.html">发起活动</a>
                    <a href="home.html">个人中心</a>
                    <a href="logout">退出</a>
                </span>
                <span v-else>
                    <a href="register.html">注册</a>
                    <a href="login.html">登录</a>
                </span>
            </span>
        </div>
    </header>
    `,
    data(){
        return{
            user:null
        };
    },
    created(){
        axios.get(
            "myInfo"
        ).then(resp=>{
            this.user=resp.data.data;
        });
    }
})